package com.woniuxy.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.daos.TbMessageDao;
import com.woniuxy.entitys.TbMessage;
import com.woniuxy.services.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageServiceImpl implements MessageService {
    @Autowired
    private TbMessageDao tbMessageDao;
    @Override
    public PageInfo<TbMessage> getMessageList(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<TbMessage> list = tbMessageDao.selectMessageList();
        PageInfo<TbMessage> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int saveMessage(TbMessage tbMessage) {
        return tbMessageDao.insert(tbMessage);
    }


    @Override
    public TbMessage getMessageByMid(Integer mid) {
        return tbMessageDao.selectByPrimaryKey(mid);
    }

    @Override
    public int updMessage(TbMessage tbMessage) {
        return tbMessageDao.updateByPrimaryKeySelective(tbMessage);
    }
}
